Skip to content

refactor(render3d): 报价只留积分,删掉供应商单价与人民币换算 - #547

Open
johnnyzhang-eng wants to merge 2 commits into
1024XEngineer:mainfrom
johnnyzhang-eng:fix/render3d-drop-remaining-cny
Open

refactor(render3d): 报价只留积分,删掉供应商单价与人民币换算#547
johnnyzhang-eng wants to merge 2 commits into
1024XEngineer:mainfrom
johnnyzhang-eng:fix/render3d-drop-remaining-cny

Conversation

@johnnyzhang-eng

Copy link
Copy Markdown
Contributor

Closes #546

问题

#482 把人民币金额从出参里删掉了,还加了反向断言「人民币金额不出参 —— 那是我们的成本,不是用户的价钱」。但它只覆盖了 render3d_service.py 一侧,供应商单价与换算留在别处:

  • tencent.pyCREDIT_PRICE_CNY = 0.12 # 后付费单价;预付费 0.09–0.1,两个 quote() 返回 (积分, 人民币)
  • render3d_assets.pyBUILD_CNY,以及一句带 约 ¥{BUILD_CNY} 的文案
  • render3d_service.py:另一句同样带 约 ¥{BUILD_CNY}

本仓是公开仓0.12 是付给供应商的后付费单价,注释里还写了预付费区间。

不把问题说重:这几处目前不会到用户眼前。它们抛 SpendNotAuthorizedValueError 子类),而 _failure.user_message 没有对应分支、会落到通用文案。所以不是外泄事故,是两件事——公开仓里留着采购成本,以及一段没有消费方的换算(quote() 的第二个返回值全仓无人读取,grep 确认)。

方案

删掉 CREDIT_PRICE_CNY 与派生的 BUILD_CNYquote() 只返回积分(tuple[int, float]int);三处文案只报积分。积分定价(CREDITS / RIG_CREDITS / BUILD_CREDITS)是产品价,一律不动。

不包含

  • 不改积分定价
  • 不改 _failure.user_message 的兜底行为
  • 不动前端。线上那句「后付费约 ¥3.6」来自 08-20 06:20 构建的旧产物,而 refactor(render3d): 成本展示只保留积分口径 #482 于当日 09:50 合入 —— 前端两侧其实都已删净,重新构建即消失,不需要代码改动

验收

packages/grep "¥\|CNY" 无命中。两条既有用例改成锁新契约,其中一条加了反向断言 assert "¥" not in str(e.value);把 ¥ 加回文案时它失败:

FAILED tests/test_render3d_tencent.py::test_model3d_refuses_to_spend_by_default

ruff check .lint-imports(2 kept, 0 broken)、export_openapiopenapi.json 无漂移、pytest -q(1317 passed, 14 skipped)。

quote() 的第二个返回值全仓无消费方;单价 0.12 是采购成本,不该留在公开仓。
三处 SpendNotAuthorized 文案改为只报积分。

Closes 1024XEngineer#546
@vercel

vercel Bot commented Aug 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
windup Ignored Ignored Preview Aug 23, 2026 5:24pm

@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本次改动把两个 provider 的 quote() 契约、消费授权异常和 orchestrator 报价统一为只返回/展示积分;调用链与测试断言整体一致。不过 provider 文档仍残留供应商单价和旧返回值说明,因此当前提交还没有完整实现 #546 所述的公开仓清理目标。

验证:追踪了仓内全部 quote() 调用方;py_compile 与固定 SHA 范围的 git diff --check 通过。当前环境未安装 uv/pytest,未能复跑 pytest。

Additional findings

  • backend/packages/framework/src/windup_framework/providers/render3d/tencent.py:10: [P1] 删除模块说明中残留的供应商单价: 模块说明仍明确写着供应商“后付费 0.12 元/积分”,所以即使 CREDIT_PRICE_CNY 常量和人民币换算已删除,公开仓依然保留了 #546 要清理的采购成本;rg '0\.12 元/积分' backend/packages 仍会命中这里。请将这段改为只描述产品积分,或完全移除供应商价格。


def quote(self, n_views: int = 1) -> tuple[int, float]:
def quote(self, n_views: int = 1) -> int:
"""返回 (积分, 预估元)。PBR、多视图各 +10 积分。纯计算,可在提交前随便调。"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 将 quote 文档同步为单个积分返回值

这里的签名和实现已改为返回 int,但 docstring 仍承诺返回 (积分, 预估元)。任何按实现文档调用或解包返回值的使用方都会得到错误指引;请把说明改成仅返回积分,并删除“预估元”。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已改:说明改成只返回积分,仓内已无 预估元 / CREDIT_PRICE_CNY 的残留。

RIG_CREDITS = 10
CREDIT_PRICE_CNY = 0.12 # 后付费单价;预付费 0.09–0.1
MAX_IMAGE_BYTES = 6 * 10**6 # ImageBase64 上限
VIEW_TYPES = ("back", "left", "right") # 正面走主参数,不在这里

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块我觉得可以统一走配置?
你看看是否可以将这些东西放在.env中?而不是在代码中写死?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

人民币单价那条本 PR 已经删掉了。剩下的 CREDITS / RIG_CREDITS / MAX_IMAGE_BYTES / VIEW_TYPES 我倾向留在代码里:它们是腾讯这个接口的事实(哪种生成模式扣多少分、ImageBase64 上限多大、多视图收哪几个字段名),不是各部署可以取不同值的东西——放进 .env 的话某个环境填错一个数,报价会静默算错而调用照样成功,等发现时费用已经产生。这和 sufy.py 里「哪个模型吃什么请求字段属该模型的 API 事实,写在代码里而不是配置里」是同一条理由。真正按部署变的(凭证、轮询间隔、超时上限)已经在 TencentCredentials.resolve() 和构造参数里了。

签名与实现已只返回积分,说明仍写着 (积分, 预估元),按它解包的调用方会拿到错误指引。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 供应商后付费单价与人民币换算仍留在公开仓(#482 未删净)

2 participants